package me.xiaoyan.java.chapter11;

import java.util.Scanner;

/**
 * 管理员类
 * @author keley
 *
 */
public class Admin {
	//用户名
	String username;
	//密码
	String password;
	
	/**
	 * 显示管理员信息
	 */
	public void show()
	{
		System.out.println("用户名:" + username);
		System.out.println("密码:" + password);
	}
	
	/**
	 * 修改密码
	 */
	public void modifyPassWord()
	{
		System.out.println("\n\n您正在修改密码...");
		Scanner input = new Scanner(System.in);
		while(true){
			System.out.print("请输入用户名:");
			String loginName = input.next();
			if(!loginName.equals(username)){
				System.out.println("用户名错误,请重新登陆!");
				continue;
			}
			System.out.print("请输入密码:");
			String loginPassword = input.next();
			if(!loginPassword.equals(password)){
				System.out.println("密码错误,请重新登陆!");
				continue;
			}
			break;
		}
		System.out.print("请输入新密码:");
		password = input.next();
		show();
	}
	
	public static void main(String[] args)
	{
		//通过Admin创建对象
		Admin admin = new Admin();
		admin.username = "小白";
		admin.password = "1234";
		admin.show();
		admin.modifyPassWord();
		
		
	}
	
}





